<?php
require_once( 'mofachi.UserBabyData.php' );
class UserBaby {
	private $user_baby;
	public function __get( $key ) {
		return $this->user_baby->$key;
	}
	public function __set( $key, $value ) {
		$this->user_baby->$key = $value;
	}
	public function __construct() {
		$this->user_baby = new UserBabyData();
		$this->is_loaded = false;
	}
	public function add() {
		if( !$this->user_id || !$this->baby_id || !$this->relation ) {
			return false;
		}	
		if ( !get_magic_quotes_gpc() ) {
			$this->user_id = addslashes( $this->user_id );
			$this->baby_id = addslashes( $this->baby_id );
			$this->relation = addslashes( $this->relation );
		}
		return $this->user_baby->add();
	}
	public function loadByID() {
		if( !$this->user_id || !$this->baby_id ) {
			return false;
		}
		return $this->user_baby->loadByID();
	}
	public function loadByUserID() {
		if( !$this->user_id ) {
			return false;
		}
		return $this->user_baby->loadByUserID();
	}
	public function loadByBabyID() {
		if( !$this->baby_id ) {
			return false;
		}
		return $this->user_baby->loadByBabyID();
	}
	public function update() {
		if( !$this->user_id || !$this->baby_id || !$this->relation ) {
			return false;
		}
		if ( !get_magic_quotes_gpc() ) {
			$this->user_id = addslashes( $this->user_id );
			$this->baby_id = addslashes( $this->baby_id );
			$this->relation = addslashes( $this->relation );
		}
		return $this->user_baby->update();
	}
	public function remove() {
		if( !$this->user_id || !$this->baby_id ) {
			return false;
		}
		$result = $this->user_baby->remove();
		if( $result )
			unset( $this->user_baby );
		return $result;
	}
	//-------------------------------------------------------------------------------------
	// static functions
	//-------------------------------------------------------------------------------------	
	public static function listData( $offset, $length ) {
		$offset = ( isset( $offset ) ) ? $offset : 0;
		$length = ( isset( $length ) ) ? $length : 20;

		return UserBabyData::listData( $offset, $length );
	}
}
?>